package com.example.api.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.AbstractRule;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.authority.AuthorityException;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowException;
import com.alibaba.csp.sentinel.slots.system.SystemBlockException;
import com.alibaba.fastjson.JSON;
import com.example.api.sentinel.FallbackHandlerResponse;
import com.example.common.Order;
import com.example.api.service.OrderService;
import com.example.common.entity.ResultDO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: microservice
 * @description: 接口
 * @author: meihua
 * @created: 2020/11/16 14:35
 */
@Controller
@RequestMapping("/order")
public class OrderController {

    private static final Logger logger= LoggerFactory.getLogger(OrderController.class);

    @Autowired
    private OrderService orderService;

    @RequestMapping("/query_order")
    @ResponseBody
    @SentinelResource(defaultFallback ="defaultFallbackResponse",fallbackClass= FallbackHandlerResponse.class)
    public ResultDO queryOrder(@RequestParam Integer orderId){
        Order order = orderService.queryOrder(orderId);
        return new ResultDO(order);
    }



}
